package com.my.mvpframe.ui.main;

import com.my.mvpframe.R;
import com.my.mvpframe.base.app.BaseActivity;
import com.my.mvpframe.utils.ActivityUtils;

import javax.inject.Inject;

import dagger.Lazy;

public class MainActivity extends BaseActivity<MainContract.View, MainPresenter> {
    @Inject
    MainPresenter presenter;
    @Inject
    Lazy<MainFragment> mainFragmentProvider;


    @Override
    protected int getLayoutId() {
        return R.layout.activity_main;
    }

    @Override
    protected void initView() {
        MainFragment fragment = (MainFragment) getSupportFragmentManager().findFragmentById(R.id.contentFrame);

        if (fragment == null) {
            fragment = mainFragmentProvider.get();
            ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), fragment, R.id.contentFrame);
        }
    }

    @Override
    protected MainPresenter initPresenter() {
        return  presenter;
    }
}
